package org.fude.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.fude.entity.User;

public interface UserMapper {
	
	@Insert("insert into "
			+ "user(uname,pwd,tel,name,sex,status,jnum,parent,uorder,parents) "
			+ "values(#{uname},#{pwd},#{tel},#{name},#{sex},#{status},#{jnum},#{parent},#{uorder},#{parents})")
	public int addUser(User user);
	
	@Select("select tel from user where tel = #{tel}")
	public String findByTel(String tel);
	
	@Select("select * from user where uname = #{uname}")
	public User findByUname(String uname);
	
	@Select("select * from user where tel = #{tel}")
	public User findUserByTel(String tel);
	
	@Select("select * from user where parent = #{id} limit #{page},#{pageSize}")
	public List<User> getChildrenUserListById(Map<String,Object> map);
	
	@Select("count (1) from user where parent = #{id}")
	public int countChildrenUserListById(int id);
	
	@Select("select * from user where parents like '%${id}%' limit #{page},#{pageSize}")
	public List<User> getDetailChildrenUserListById(Map<String,Object> map);

	@Select("select count(1) from user")
	public int countTotal();
}
